package com.dao.td_questiondao;

import com.entity.Td_tbquestionbank;
import org.springframework.beans.factory.annotation.Autowired;

import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import java.util.List;

public class Td_questionDaoImpl {

    @Autowired
    private EntityManager entityManager;

    public List<Td_tbquestionbank> getAllByFd_ID(String id){
        String sql="select * from Td_tbquestionbank where Fd_ID="+id;
        String[] ids = id.split(",");
        for (int i=1;i<ids.length;i++){
            sql+=" or fd_id="+ids[i];
        }

        TypedQuery<Td_tbquestionbank> namedQuery = entityManager.createNamedQuery(sql, Td_tbquestionbank.class);
        return namedQuery.getResultList();
    }
}
